package com.hx.er.common.logic;

import java.util.ArrayList;
import java.util.List;

import com.hx.er.common.entity.FlotDataEntity;
import com.hx.er.common.util.StringUtil;

public class FlotManager {
	private List<String> labelList;
	private String flotDataStr;

	public FlotManager(List<FlotDataEntity> entityList) {
		// 校验列表是否为空
		if (entityList == null || entityList.size() == 0) {
			this.flotDataStr = StringUtil.EMPTY;
		}

		this.labelList = new ArrayList<>();
		StringBuilder sb = new StringBuilder();

		sb.append("[");
		for (int i = 0; i < entityList.size(); i++) {
			// 获取数据实体
			FlotDataEntity flotEntity = entityList.get(i);
			// 获取数据列表
			List<String[]> dataList = flotEntity.getDataList();
			for (int j = 0; j < dataList.size(); j++) {
				// 记录数据
				sb.append("[");
				sb.append(dataList.get(j)[0]);
				sb.append(",");
				sb.append(dataList.get(j)[1]);
				sb.append("]");
			}

			if (i != entityList.size() - 1) {
				sb.append(",");
			}

			// 记录标签列表
			this.labelList.add(flotEntity.getLabel());
		}
		sb.append("]");

		this.flotDataStr = sb.toString();
	}

	public List<String> getLabelList() {
		return this.labelList;
	}

	public String getFlotDataStr() {
		return this.flotDataStr;
	}
}
